package com.yswy.domain.entity.tf;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yswy.common.enums.TriggerNodeEnums;
import com.yswy.common.enums.XtPlatformEnums;
import com.yswy.common.enums.base.Type3Enum;
import com.yswy.common.enums.base.TypeEnum;
import com.yswy.domain.vo.gld.addOrUpate.TgDeductionChildAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.TgEventChildAddOrUpdate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
@AllArgsConstructor
@Api(tags = "事件配置")
@TableName(value = "tg_event_child")
public class TgEventChild {
    @TableId(type = IdType.AUTO)
    private Long eventChildId;
    @ApiModelProperty("扣量配置ID")
    private Long tgEventId;

    @ApiModelProperty("排序ID")
    private Integer sortId;

    @ApiModelProperty("触发节点")
    private String triggerNode;


    @ApiModelProperty("回传keyId")
    private Long eventId;

    @ApiModelProperty("延时回传时间(分钟)")
    private Integer delayTimeNum;

    @TableField(exist = false)
    @ApiModelProperty("回传key")
    private String eventKey ;
    @TableField(exist = false)
    @ApiModelProperty("缓存时间(天)")
    private Integer cacheTime ;
    @TableField(exist = false)
    @ApiModelProperty("事件名字")
    private String eventName ;
    @TableField(exist = false)
    @ApiModelProperty("是否扣量 0 不开启   1 开启")
    private Integer isBuckle ;

    public TgEventChild(TgEventChildAddOrUpdate res, Long tgEventId){
        this.tgEventId =tgEventId;

        TypeEnum triggerNodeEnumsEnum = TypeEnum.messageOf(TriggerNodeEnums.class , res.getTriggerNode());
        this.triggerNode =triggerNodeEnumsEnum.toString();

        this.eventId =res.getEventId();
        if (res.getDelayTimeNum() == null){
            this.delayTimeNum = 0 ;
        }else {
            this.delayTimeNum =res.getDelayTimeNum();
        }
        this.sortId =res.getSortId();
    }
    public TgEventChild(){

    }

}
